package com.ziyun.pop.modules.mercharReport.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.ziyun.pop.modules.mercharReport.dao.ReportStoreApplyDao;
import com.ziyun.pop.modules.mercharReport.entity.ReportStoreApplyEntity;
import com.ziyun.pop.modules.mercharReport.entity.ReportStoreApplyVO;
import com.ziyun.pop.modules.mercharReport.service.ReportStoreApplyService;
import io.renren.common.utils.PageUtils;
import io.renren.common.utils.Query;
import io.renren.common.utils.R;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Map;


@Service("reportStoreApplyService")
public class ReportStoreApplyServiceImpl extends ServiceImpl<ReportStoreApplyDao, ReportStoreApplyEntity> implements ReportStoreApplyService {

    @Autowired
    private ReportStoreApplyDao reportStoreApplyDao;

    @Override
    public PageUtils queryPage(Map<String, Object> params) {
        Page<ReportStoreApplyEntity> page = (Page<ReportStoreApplyEntity>) this.page(
                new Query<ReportStoreApplyEntity>(params).getPage(),
                new QueryWrapper<ReportStoreApplyEntity>()
        );

        return new PageUtils(page);
    }

    @Override
    public R listPage(Map<String, Object> params) {

        Page<ReportStoreApplyVO> page = new Page<>();
        page.setCurrent(Integer.valueOf(params.get("page").toString()));
        page.setSize(Integer.valueOf(params.get("limit").toString()));
        List<ReportStoreApplyVO> list = reportStoreApplyDao.listPage(page, params);
        page.setRecords(list);
        PageUtils pageUtils = new PageUtils(page);
        return R.ok().put("page", pageUtils);
    }

    @Override
    public List<ReportStoreApplyVO> exportExcel(Map<String, Object> params) {
        return reportStoreApplyDao.listPage(params);
    }

}
